//
//  ViewController.swift
//  自定义tabbar和navigationbar
//
//  Created by lete on 2020/4/24.
//  Copyright © 2020 lete. All rights reserved.
//

import UIKit

class ViewController: UIViewController {
    
    let screenSize =  UIScreen.main.bounds.size
    
    
    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view.
        
        self.view.backgroundColor = UIColor.white
        
        self.initBtn()
        initNavBtn()
        
    }
    
    //Mark: 模态页面
    //初始化按钮，点击按钮跳转页面
    func initBtn(){
        //        let screenSize =  UIScreen.main.bounds.size
        
        let jumpBtn  = UIButton(type: UIButton.ButtonType.custom)
        jumpBtn.setTitle("模态跳转", for: .normal)
        jumpBtn.frame = CGRect(x: screenSize.width/4-50, y: screenSize.height/4-50, width: 100, height: 100)
        jumpBtn.backgroundColor = UIColor(red: 50/255, green: 123/255, blue: 203/255, alpha: 1)
        jumpBtn.setTitleColor(UIColor.white, for: .normal)
        //按钮绑定事件，点击时执行
        jumpBtn.addTarget(self, action:  #selector(pageJump), for: .touchDown)
        
        self.view.addSubview(jumpBtn)
        
        
        
        
    }
    
    @objc func pageJump() {
        //创建一个页面
        let nextVc = AViewController()
        //取目标页面的一个变量进行赋值，以属性的方式进行传值。
        nextVc.message = "传递的值"
        //跳转
        self.present(nextVc, animated: true, completion: nil)
        
        
    }
    
    
    
    
    //Mark: nav页面
    //初始化按钮，点击按钮跳转页面
    func initNavBtn(){
        
        let navBtn  = UIButton(type: UIButton.ButtonType.custom)
        navBtn.setTitle("nav跳转", for: .normal)
        navBtn.frame = CGRect(x: screenSize.width/2-50, y: screenSize.height/2-50, width: 100, height: 100)
        navBtn.backgroundColor = UIColor(red: 50/255, green: 123/255, blue: 203/255, alpha: 1)
        navBtn.setTitleColor(UIColor.white, for: .normal)
        //按钮绑定事件，点击时执行
        navBtn.addTarget(self, action:  #selector(pageNavJump), for: .touchDown)
        
        self.view.addSubview(navBtn)
        
    }
    @objc func pageNavJump() {
        //创建一个页面
        let nextVc = BViewController()
        //取目标页面的一个变量进行赋值，以属性的方式进行传值。
        nextVc.message = "nav传递的值"
        //跳转
        //跳转
        self.navigationController?.pushViewController(nextVc, animated: true)
    }
}

